# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

package(default_visibility = ["//visibility:public"])

proto_library(
    name = "core_proto",
    srcs = ["core.proto"],
)

proto_library(
    name = "status_code_proto",
    srcs = ["status_code.proto"],
)

proto_library(
    name = "ccl_proto",
    srcs = ["ccl.proto"],
)

proto_library(
    name = "scdb_api_proto",
    srcs = ["scdb_api.proto"],
    deps = [
        ":common_proto",
        ":core_proto",
        ":engine_proto",
        ":status_proto",
        "@com_google_protobuf//:empty_proto",
        "@googleapis//google/api:annotations_proto",
        "@googleapis//google/api:field_behavior_proto",
    ],
)

proto_library(
    name = "engine_proto",
    srcs = ["engine.proto"],
    deps = [
        ":common_proto",
        ":core_proto",
        ":status_proto",
        ":subgraph_proto",
        "@com_google_protobuf//:empty_proto",
        "@spulib//libspu:spu_proto",
    ],
)

proto_library(
    name = "status_proto",
    srcs = ["status.proto"],
    deps = [
        "@com_google_protobuf//:any_proto",
    ],
)

proto_library(
    name = "common_proto",
    srcs = ["common.proto"],
    deps = [
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

cc_proto_library(
    name = "common_cc_proto",
    deps = [":common_proto"],
)

cc_proto_library(
    name = "engine_cc_proto",
    deps = [":engine_proto"],
)

cc_proto_library(
    name = "core_cc_proto",
    deps = [":core_proto"],
)

cc_proto_library(
    name = "status_cc_proto",
    deps = [":status_code_proto"],
)

proto_library(
    name = "broker_proto",
    srcs = ["broker.proto"],
    deps = [
        ":common_proto",
        ":core_proto",
        ":interpreter_proto",
        ":status_proto",
        "@com_google_protobuf//:timestamp_proto",
        "@googleapis//google/api:annotations_proto",
        "@googleapis//google/api:field_behavior_proto",
        "@spulib//libspu:spu_proto",
    ],
)

java_proto_library(
    name = "broker_java_proto",
    deps = [
        ":broker_proto",
    ],
)

proto_library(
    name = "subgraph_proto",
    srcs = [
        "subgraph.proto",
    ],
    deps = [":core_proto"],
)

proto_library(
    name = "interpreter_proto",
    srcs = ["interpreter.proto"],
    deps = [
        ":common_proto",
        ":ccl_proto",
        ":core_proto",
        ":status_proto",
        ":subgraph_proto",
        "@com_google_protobuf//:timestamp_proto",
        "@spulib//libspu:spu_proto",
    ],
)

go_proto_library(
    name = "spu_go_proto",
    importpath = "github.com/secretflow/scql/pkg/proto-gen/spu",
    protos = ["@spulib//libspu:spu_proto"],
)

go_proto_library(
    name = "googleapis_go_proto",
    importpath = "google.golang.org/genproto/googleapis/api",
    protos = [
        "@googleapis//google/api:annotations_proto",
        "@googleapis//google/api:field_behavior_proto",
        "@googleapis//google/api:http_proto",
    ],
)

go_proto_library(
    name = "scql_go_proto",
    compilers = ["@io_bazel_rules_go//proto:go_grpc"],
    importpath = "github.com/secretflow/scql/pkg/proto-gen/scql",
    protos = [
        ":broker_proto",
        ":ccl_proto",
        ":common_proto",
        ":core_proto",
        ":engine_proto",
        ":interpreter_proto",
        ":scdb_api_proto",
        ":status_code_proto",
        ":status_proto",
        ":subgraph_proto",
    ],
    deps = [
        ":googleapis_go_proto",
        ":spu_go_proto",
    ],
)
